package servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import dto.Page;
import service.EmployeeService;
import serviceImpl.EmployeeServiceImpl;

/**
 * 
 */
public class EmployeeListServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	EmployeeService employeeService=new EmployeeServiceImpl();
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String pageNo = request.getParameter("pageNo");
		String pageSize = request.getParameter("pageSize");
		Page page = employeeService.getEmployeeList(Integer.parseInt(pageNo), Integer.parseInt(pageSize));
		String json = JSON.toJSONString(page, SerializerFeature.WriteDateUseDateFormat);
		response.getWriter().write(json);
		
	
	}

}
